package distrcomp;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import javax.rmi.ssl.SslRMIClientSocketFactory;
import javax.rmi.ssl.SslRMIServerSocketFactory;

/*
 * Implementation of the tracker
 */

public class ClientTrackerImpl extends UnicastRemoteObject implements ShippingTracker {
	private static final long serialVersionUID = 1L;
	private Shipment shipment;
	
	//Constructor
	public ClientTrackerImpl(Shipment shipment) throws RemoteException {
		super(0, new SslRMIClientSocketFactory(), new SslRMIServerSocketFactory(null, null, true));
		this.shipment = shipment;
	}

	//Update the shipping state
	public void updateStatus(ShippingState newState) throws RemoteException {
		this.shipment.setShippingState(newState);
	}
	
	//Get the current shipping state
	public ShippingState getState() throws RemoteException {
		return this.shipment.getShippingState();
	}
	
}